package vip.specimen.system.datasource.entity;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
/**
 * *@Author: 余浪人
 * *@Date：2021/2/23 17:12
 * *@Email:yulangren520@Gmail.com
 * *@QQ:1368419640
 **/
@Getter
@Setter
@Entity
@Table(name = "system_permission")
public class SystemPermissionEntity extends BaseEntity {
    @Column(length = 32)
    @ApiModelProperty(value = "权限名称")
    private String permissionName;
    @Column(columnDefinition = "enum('menu','button','connector')")
    @ApiModelProperty(value = "权限资源类型")
    private String resourceType;
    @ApiModelProperty(value = "权限地址")
    private String url;
    @ApiModelProperty(value = "权限标识")
    private String permission;//权限字符串,menu例子：role:*，button例子：role:create,role:update,role:delete,role:view
    @ManyToOne
    @ApiModelProperty(value = "权限上级", dataType = "SystemPermissionEntity")
    private SystemPermissionEntity parent; // 父
//    @ManyToMany(fetch = FetchType.LAZY)
//    @JoinTable(name = "permission_role", joinColumns = { @JoinColumn(name = "permission_uuid") }, inverseJoinColumns = {@JoinColumn(name = "role_uuid") })
//    private List<SystemRoleEntity> roles;

    public SystemPermissionEntity() {
    }

    public SystemPermissionEntity(String permissionName, String resourceType, String url, String permission, SystemPermissionEntity parent) {
        this.permissionName = permissionName;
        this.resourceType = resourceType;
        this.url = url;
        this.permission = permission;
        this.parent = parent;
//        this.roles = roles;
    }

    @Override
    public String toString() {
        return "SystemPermissionEntity{" +
                "permissionName='" + permissionName + '\'' +
                ", resourceType='" + resourceType + '\'' +
                ", url='" + url + '\'' +
                ", permission='" + permission + '\'' +
                ", parent=" + parent +
                ", id=" + id +
                ", uuid=" + uuid +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                '}';
    }
}
